package com.espirit.eap.manager;
import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.espirit.common.RelatedFile;
import com.espirit.eap.annotation.DomainModel;
@Entity
@DomainModel
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class SystemSetting implements Serializable {
	private static final long serialVersionUID = 1616973087183872361L;
	private Integer id;
	private GlobalSetting globalSetting;
	private List<RelatedFile> printTemplate;

	@Id
	@GeneratedValue
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public void setGlobalSetting(GlobalSetting globalSetting) {
		this.globalSetting = globalSetting;
	}

	@Embedded
	public GlobalSetting getGlobalSetting() {
		return globalSetting;
	}
	
	public GlobalSetting safeGlobalSetting(){
		if (globalSetting == null){
			globalSetting = new GlobalSetting();
		}
		return globalSetting;
	}

	@OneToMany(targetEntity=RelatedFile.class,fetch=FetchType.EAGER,mappedBy="systemSetting",cascade=CascadeType.ALL)
	public List<RelatedFile> getPrintTemplate() {
		return printTemplate;
	}

	public void setPrintTemplate(List<RelatedFile> printTemplate) {
		this.printTemplate = printTemplate;
	}

	

	public static  final String NEED_DELIVERYNOTIFY = "setting.needDeliveryNotify";
	
	private Boolean needDeliveryNotify ;
	
	@Transient
	public Boolean getNeedDeliveryNotify() {
		return needDeliveryNotify;
	}

	public void setNeedDeliveryNotify(Boolean needDeliveryNotify) {
		this.needDeliveryNotify = needDeliveryNotify;
	}
}
